package com.yizhang.web;

import com.yizhang.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: yi.zhang
 * @CreateTime: 2025-06-20 15:16:10
 * @Description:
 */
@WebServlet(urlPatterns = "/userServlet", loadOnStartup = 7)
public class UserServlet extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
        UserService bean = applicationContext.getBean(UserService.class);
        bean.show();
    }
}
